/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import model.LevelInterpreter.Difficulties;
import model.LevelInterpreter.Parts;
import model.LevelManager;
import model.LevelSpecification;
import model.LevelSpecificationBuilder;
import utilities.ImageFilter;

/**
 *
 * @author misja
 */
public class LevelSpecificationBuilderFrame extends javax.swing.JFrame {

    private LevelSpecificationBuilder levelSpecificationBuilder;

    public LevelSpecificationBuilderFrame(LevelSpecification levelSpecification) {
        initComponents();
        this.levelSpecificationBuilder = new LevelSpecificationBuilder(levelSpecification);
        this.txtLevelName.setText(levelSpecificationBuilder.getLevelSpecification().getName());
        this.txtRows.setText("" + levelSpecificationBuilder.getLevelSpecification().getFieldSpecification().length);
        this.txtColumns.setText("" + levelSpecificationBuilder.getLevelSpecification().getFieldSpecification()[0].length);
        this.txtFirstXCoordinate.setText("" + 0);
        this.txtFirstYCoordinate.setText("" + 0);
        this.txtSecondXCoordinate.setText("" + 0);
        this.txtSecondYCoordinate.setText("" + 0);
        this.cboDifficulty.setSelectedItem(levelSpecificationBuilder.getLevelSpecification().getDifficulty());
        this.draw();
    }

    public LevelSpecificationBuilderFrame() {
        initComponents();
        this.levelSpecificationBuilder = new LevelSpecificationBuilder();
        this.txtLevelName.setText(levelSpecificationBuilder.getLevelSpecification().getName());
        this.txtRows.setText("" + 0);
        this.txtColumns.setText("" + 0);
        this.txtFirstXCoordinate.setText("" + 0);
        this.txtFirstYCoordinate.setText("" + 0);
        this.txtSecondXCoordinate.setText("" + 0);
        this.txtSecondYCoordinate.setText("" + 0);
        this.cboDifficulty.setSelectedItem(levelSpecificationBuilder.getLevelSpecification().getDifficulty());
    }

    private void messageDialog(ArrayList<String> messages) {
        String message = "";
        Iterator<String> it = messages.iterator();
        while (it.hasNext()) {
            message = message + it.next() + "\n";
        }
        JOptionPane.showMessageDialog(rootPane, message);
    }

    private void messageDialog(String message) {
        JOptionPane.showMessageDialog(rootPane, message);
    }

    private void draw() {
        this.pnlFields.draw(this.levelSpecificationBuilder.getInterpretedLevel());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtRows = new javax.swing.JTextField();
        txtColumns = new javax.swing.JTextField();
        btnGenerateField = new javax.swing.JButton();
        txtFirstXCoordinate = new javax.swing.JTextField();
        txtFirstYCoordinate = new javax.swing.JTextField();
        btnSetParts = new javax.swing.JButton();
        txtLevelName = new javax.swing.JTextField();
        txtSecondXCoordinate = new javax.swing.JTextField();
        txtSecondYCoordinate = new javax.swing.JTextField();
        lblDivider = new javax.swing.JLabel();
        lblName = new javax.swing.JLabel();
        lblRows = new javax.swing.JLabel();
        lblColumns = new javax.swing.JLabel();
        lblXCoordinate = new javax.swing.JLabel();
        lblYCoordinate = new javax.swing.JLabel();
        btnAddImage = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();
        lblDivider1 = new javax.swing.JLabel();
        lblPartType = new javax.swing.JLabel();
        lblImageType = new javax.swing.JLabel();
        pnlFields = new view.FieldPanel();
        lblDifficulty = new javax.swing.JLabel();
        mbMain = new javax.swing.JMenuBar();
        mNavigation = new javax.swing.JMenu();
        miHome = new javax.swing.JMenuItem();
        miLevelManager = new javax.swing.JMenuItem();
        miLevelSelection = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Builder");
        setResizable(false);

        btnGenerateField.setText("Generate");
        btnGenerateField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGenerateFieldActionPerformed(evt);
            }
        });

        txtFirstXCoordinate.setText("0");

        txtFirstYCoordinate.setText("0");

        cboPartType.setModel(new DefaultComboBoxModel<>(Parts.values()));

        btnSetParts.setText("Set");
        btnSetParts.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSetPartsActionPerformed(evt);
            }
        });

        txtSecondXCoordinate.setText("0");

        txtSecondYCoordinate.setText("0");

        lblDivider.setText("-");

        lblName.setText("Name");

        lblRows.setText("Rows");

        lblColumns.setText("Columns");

        lblXCoordinate.setText("X");

        lblYCoordinate.setText("Y");

        cboImageType.setModel(new DefaultComboBoxModel<>(Parts.values()));

        btnAddImage.setText("Add");
        btnAddImage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddImageActionPerformed(evt);
            }
        });

        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        lblDivider1.setText("-");

        lblPartType.setText("Part");

        lblImageType.setText("Image");

        javax.swing.GroupLayout pnlFieldsLayout = new javax.swing.GroupLayout(pnlFields);
        pnlFields.setLayout(pnlFieldsLayout);
        pnlFieldsLayout.setHorizontalGroup(
            pnlFieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 598, Short.MAX_VALUE)
        );
        pnlFieldsLayout.setVerticalGroup(
            pnlFieldsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 598, Short.MAX_VALUE)
        );

        cboDifficulty.setModel(new DefaultComboBoxModel<>(Difficulties.values()));
        cboDifficulty.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboDifficultyActionPerformed(evt);
            }
        });

        lblDifficulty.setText("Difficulty");

        mNavigation.setText("Navigation");

        miHome.setText("Home");
        miHome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miHomeActionPerformed(evt);
            }
        });
        mNavigation.add(miHome);

        miLevelManager.setText("Level Manager");
        miLevelManager.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miLevelManagerActionPerformed(evt);
            }
        });
        mNavigation.add(miLevelManager);

        miLevelSelection.setText("Level Selection");
        miLevelSelection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miLevelSelectionActionPerformed(evt);
            }
        });
        mNavigation.add(miLevelSelection);

        mbMain.add(mNavigation);

        setJMenuBar(mbMain);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(lblImageType)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cboImageType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(lblXCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtFirstXCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lblDivider1, javax.swing.GroupLayout.PREFERRED_SIZE, 4, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtSecondXCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(lblColumns)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtColumns, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(lblRows)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtRows, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(btnGenerateField, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(lblName)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtLevelName, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(btnSetParts, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(lblPartType)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cboPartType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(lblYCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtFirstYCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lblDivider)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtSecondYCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnAddImage, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(lblDifficulty)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboDifficulty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(btnSave, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlFields, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlFields, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtLevelName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblName))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblRows)
                            .addComponent(txtRows, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtColumns, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblColumns))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnGenerateField, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtFirstXCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtSecondXCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblXCoordinate)
                            .addComponent(lblDivider1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtFirstYCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtSecondYCoordinate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblDivider)
                            .addComponent(lblYCoordinate))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cboPartType, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblPartType))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSetParts, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cboImageType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblImageType))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnAddImage)
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cboDifficulty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblDifficulty))
                        .addGap(18, 18, 18)
                        .addComponent(btnSave)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnGenerateFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateFieldActionPerformed

        if (this.levelSpecificationBuilder.getLevelSpecification().getImage(Parts.FIELD) == null) {
            this.messageDialog("Voeg eerst een terrain plaatje toe");
            return;
        }

        if (this.levelSpecificationBuilder.getLevelSpecification().getFieldSpecification() != null) {
            int reply = JOptionPane.showConfirmDialog(null, "Opnieuw genereren wist het speelveld", "Pas Op!", JOptionPane.YES_NO_OPTION);
            if (reply == JOptionPane.NO_OPTION) {
                return;
            }
        }

        try {
            int rows = Integer.parseInt(txtRows.getText());
            int columns = Integer.parseInt(txtColumns.getText());

            if (!this.levelSpecificationBuilder.generateFieldSpecification(rows, columns)) {
                this.messageDialog(this.levelSpecificationBuilder.getMsg());
                this.levelSpecificationBuilder.clearMsg();
                return;
            }
        } catch (NumberFormatException e) {
            this.messageDialog("Voer alleen gehele getallen in 0 is niet toegestaan");
        }

        this.draw();
    }//GEN-LAST:event_btnGenerateFieldActionPerformed

    private void btnSetPartsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetPartsActionPerformed

        if (this.levelSpecificationBuilder.getLevelSpecification().getFieldSpecification() == null) {
            this.messageDialog("Genereer eerst een speelveld");
            return;
        }

        if (!this.levelSpecificationBuilder.getLevelSpecification().imageExists((Parts) cboPartType.getModel().getSelectedItem())) {
            this.messageDialog("Voeg eerst het plaatje toe van het " + cboPartType.getModel().getSelectedItem().toString());
            return;
        }

        try {
            int xFirst = Integer.parseInt(txtFirstXCoordinate.getText());
            int yFirst = Integer.parseInt(txtFirstYCoordinate.getText());
            int xSecond = Integer.parseInt(txtSecondXCoordinate.getText());
            int ySecond = Integer.parseInt(txtSecondYCoordinate.getText());

            if (!this.levelSpecificationBuilder.editFieldSpecification(xFirst, xSecond, yFirst, ySecond, (Parts) cboPartType.getModel().getSelectedItem())) {
                this.messageDialog(this.levelSpecificationBuilder.getMsg());
                this.levelSpecificationBuilder.clearMsg();
                return;
            }

            this.draw();
        } catch (NumberFormatException e) {
            this.messageDialog("Voer alleen gehele getallen in 0 is toegestaan");
        }
    }//GEN-LAST:event_btnSetPartsActionPerformed

    private void btnAddImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddImageActionPerformed

        final JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileFilter(new ImageFilter());
        int returnValue = fileChooser.showOpenDialog(this);

        if (returnValue == JFileChooser.APPROVE_OPTION) {

            File file = fileChooser.getSelectedFile();

            try {
                BufferedImage image = ImageIO.read(file);
                Parts part = (Parts) cboImageType.getModel().getSelectedItem();

                if (!this.levelSpecificationBuilder.getLevelSpecification().setImage(part, image)) {
                    this.messageDialog(this.levelSpecificationBuilder.getLevelSpecification().getMsg());
                    this.levelSpecificationBuilder.getLevelSpecification().clearMsg();
                }

            } catch (IOException ex) {
                this.messageDialog("Laat alleen .jpg, .gif en png bestanden in");
            }
            this.draw();
        }
    }//GEN-LAST:event_btnAddImageActionPerformed

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed

        if (this.txtLevelName.getText() == null) {
            this.messageDialog("Geef het level een naam");
            return;
        }

        LevelManager levelManager = new LevelManager();
        boolean levelSaved;
        if (levelManager.levelExist(this.txtLevelName.getText())) {

            Object[] options = {"Ja", "Nee"};
            int returnValue = JOptionPane.showOptionDialog(rootPane, "Het level bestaat al wilt u het overschrijven?", "Let op!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (returnValue == JOptionPane.YES_OPTION) {
                levelSaved = levelManager.save(this.txtLevelName.getText(), this.levelSpecificationBuilder.getLevelSpecification(), true);
            } else {
                return;
            }
        } else {
            levelSaved = levelManager.save(this.txtLevelName.getText(), this.levelSpecificationBuilder.getLevelSpecification(), false);
        }

        if (levelSaved) {
            new LevelManagerFrame().setVisible(true);
            this.dispose();
        } else {
            this.messageDialog(levelManager.getMsg());
            levelManager.clearMsg();
        }
    }//GEN-LAST:event_btnSaveActionPerformed

    private void cboDifficultyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboDifficultyActionPerformed
        this.levelSpecificationBuilder.getLevelSpecification().setDifficulty((Difficulties) cboDifficulty.getModel().getSelectedItem());
    }//GEN-LAST:event_cboDifficultyActionPerformed

    private void miLevelSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miLevelSelectionActionPerformed
        new LevelSelectionFrame().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_miLevelSelectionActionPerformed

    private void miLevelManagerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miLevelManagerActionPerformed
        new LevelManagerFrame().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_miLevelManagerActionPerformed

    private void miHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miHomeActionPerformed
        new HomeFrame().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_miHomeActionPerformed
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new LevelSpecificationBuilderFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddImage;
    private javax.swing.JButton btnGenerateField;
    private javax.swing.JButton btnSave;
    private javax.swing.JButton btnSetParts;
    private final javax.swing.JComboBox cboDifficulty = new javax.swing.JComboBox<Difficulties>();
    private final javax.swing.JComboBox cboImageType = new javax.swing.JComboBox<Parts>();
    private final javax.swing.JComboBox cboPartType = new javax.swing.JComboBox<Parts>();
    private javax.swing.JLabel lblColumns;
    private javax.swing.JLabel lblDifficulty;
    private javax.swing.JLabel lblDivider;
    private javax.swing.JLabel lblDivider1;
    private javax.swing.JLabel lblImageType;
    private javax.swing.JLabel lblName;
    private javax.swing.JLabel lblPartType;
    private javax.swing.JLabel lblRows;
    private javax.swing.JLabel lblXCoordinate;
    private javax.swing.JLabel lblYCoordinate;
    private javax.swing.JMenu mNavigation;
    private javax.swing.JMenuBar mbMain;
    private javax.swing.JMenuItem miHome;
    private javax.swing.JMenuItem miLevelManager;
    private javax.swing.JMenuItem miLevelSelection;
    private view.FieldPanel pnlFields;
    private javax.swing.JTextField txtColumns;
    private javax.swing.JTextField txtFirstXCoordinate;
    private javax.swing.JTextField txtFirstYCoordinate;
    private javax.swing.JTextField txtLevelName;
    private javax.swing.JTextField txtRows;
    private javax.swing.JTextField txtSecondXCoordinate;
    private javax.swing.JTextField txtSecondYCoordinate;
    // End of variables declaration//GEN-END:variables
}
